package com.ruoyi.web.controller.durian;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.durian.service.LlMapService;
import com.ruoyi.durian.service.LlOrderService;
import com.ruoyi.durian.service.LlSearchHistoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 打车控制器
 */
@RestController
@RequestMapping("/taxi")
public class TaxiController extends BaseController {

    @Resource
    private LlSearchHistoryService llSearchHistoryService;

    @Resource
    private LlOrderService llOrderService;

    @Resource
    private LlMapService llMapService;

    /**
     * 历史搜索记录
     *
     * @return
     */
    @GetMapping("/searchHistory")
    public TableDataInfo searchHistory() {
        startPage();
        return getDataTable(llSearchHistoryService.searchHistory());
    }

    /**
     * 搜索记录
     * @param name
     * @return
     */
    @PostMapping("/search/like")
    public TableDataInfo searchLike(@RequestParam("name") String name) {
        return getDataTable(llSearchHistoryService.searchLike(name));
    }

    /**
     * 搜索地图的详情
     * @param id
     * @return
     */
    @GetMapping("/search/search/{id}")
    public AjaxResult search(@PathVariable("id") Integer id) {
        return llMapService.search(id);
    }

    /**
     * 乘客取消订单
     *
     * @param orderId  订单id
     * @return
     */
    @PostMapping("/close/order")
    public AjaxResult closeOrder(Integer orderId) {
        return llOrderService.closeOrder(orderId);
    }

}
